package com.example.baselibs.utils;

import android.content.Context;

import com.blankj.utilcode.constant.PermissionConstants;
import com.blankj.utilcode.util.PermissionUtils;

import java.util.List;

/**
 * 动态权限申请
 */
public class RequestPermission {
    private static String[] permissions={
            PermissionConstants.STORAGE,
            PermissionConstants.CALENDAR,
            PermissionConstants.CAMERA,
            PermissionConstants.CONTACTS,
            PermissionConstants.LOCATION,
            PermissionConstants.MICROPHONE,
            PermissionConstants.PHONE,
            PermissionConstants.SENSORS,
            PermissionConstants.SMS
    };

    public static void requestAllPermission(Context context){
        PermissionUtils.permission(permissions).callback(new PermissionUtils.FullCallback() {
            @Override
            public void onGranted(List<String> permissionsGranted) {

            }

            @Override
            public void onDenied(List<String> permissionsDeniedForever, List<String> permissionsDenied) {
                ActivityUtils.showToast(context,"请打开权限");
                PermissionUtils.launchAppDetailsSettings();
            }
        }).request();
    }

}
